package com.ycfmedical.bed.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.bilibili.magicasakura.widgets.TintTextView;
import com.ycfmedical.bed.HisConstants;
import com.ycfmedical.bed.R;
import com.ycfmedical.bed.local.entity.HisSystemInfo;

import butterknife.BindView;
import cn.droidlover.xdroidmvp.base.SimpleRecAdapter;
import cn.droidlover.xdroidmvp.kit.KnifeKit;

/**
 * Created by Administrator on 2017/3/16 0016. 历史用药记录Adapter
 */

public class HisMedicineInfoAdapter extends SimpleRecAdapter<HisSystemInfo, HisMedicineInfoAdapter.ViewHolder>
{
    public static final int TAG_VIEW = 0;

    public HisMedicineInfoAdapter(Context context)
    {
        super(context);
    }

    @Override
    public ViewHolder newViewHolder(View itemView)
    {
        return new ViewHolder(itemView);
    }

    @Override
    public int getLayoutId()
    {
        return R.layout.adapter_medicine;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position)
    {
        final HisSystemInfo item = data.get(position);
        // ILFactory.getLoader().loadNet(holder.ivCover, item.getImg(), null);
        // 标题栏
        holder.name.setText(HisConstants.MEDICINENAME);
        holder.number.setText(HisConstants.MEDICINENUM);
        holder.data.setText(HisConstants.MEDICINEDATA);
        holder.administrative.setText(HisConstants.ADMINISTRATIVE);
        holder.comment.setText(HisConstants.MEDICINECOMMENT);
        // 药品名称
        holder.medicineName.setText(item.getMedicinename());
        holder.medicineNumber.setText(item.getMedicinenum());
        holder.medicineData.setText(item.getMedicinedata());
        holder.medicineAdministrative.setText(item.getAdministrative());
        holder.medicineComment.setText(item.getMedicinecomment());
        holder.itemView.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                if (getRecItemClick() != null)
                {
                    getRecItemClick().onItemClick(position, item, TAG_VIEW, holder);
                }
            }
        });
    }

    public static class ViewHolder extends RecyclerView.ViewHolder
    {
        @BindView(R.id.name)
        TintTextView name;
        @BindView(R.id.number)
        TintTextView number;
        @BindView(R.id.data)
        TintTextView data;
        @BindView(R.id.administrative)
        TintTextView administrative;
        @BindView(R.id.comment)
        TintTextView comment;
        @BindView(R.id.medicine_name)
        TintTextView medicineName;
        @BindView(R.id.medicine_number)
        TintTextView medicineNumber;
        @BindView(R.id.medicine_data)
        TintTextView medicineData;
        @BindView(R.id.medicine_administrative)
        TintTextView medicineAdministrative;
        @BindView(R.id.medicine_comment)
        TintTextView medicineComment;

        public ViewHolder(View itemView)
        {
            super(itemView);
            KnifeKit.bind(this, itemView);
        }
    }
}
